package com.digua.atools.tools;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author:digua
 * @dat:2021/9/28
 * @description:时间工具类
 */
public class DateUtil {
    public static String FORMAT_DEF = "yyyy-MM-dd HH:mm:ss";

    public static String format(Date date) {
        if (date == null) {
            return "";
        }
        return new SimpleDateFormat(FORMAT_DEF).format(date);
    }

    public static String format(Date date, String formatStr) {
        if (date == null) {
            return "";
        }
        return new SimpleDateFormat(StrUtil.isBlank(formatStr) ? FORMAT_DEF : formatStr).format(date);
    }

}
